import Vue from 'vue'
import Router from 'vue-router'

const login = () => import('@/components/login')
const reg = () => import('@/components/reg')
const wel = () => import('@/components/welcome')
const lode = () => import('@/components/loding')
const Welpage = () => import('@/components/welpage')
const main = () => import('@/components/main')
const Chatlist = () => import('@/components/chatlist')
const Chatmessage = () => import('@/components/chatmessage')
const welcomefirst = () => import('@/components/welcomefirst')
// 路由懒加载

Vue.use(Router)

export default new Router({
  // mode: 'history',
  // base: process.env.BASE_URL,
  scrollBehavior (to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  },
  routes: [
    {
      path: '/',
      redirect: '/wel/welcome'
    },
    {
      path: '/wel',
      component: Welpage,
      children: [
        {
          path: 'log',
          name: 'login',
          component: login
        },
        {
          path: 'reg',
          name: 'reg',
          component: reg
        },
        {
          path: 'welcome',
          name: 'welcome',
          component: wel
        },
        {
          path: 'loding',
          name: 'lode',
          component: lode
        },
        {
          path:'welcomefirst',
          name:'welcomefirst',
          component:welcomefirst
        }
      ]
    },
    {
      path: '/main',
      name: 'main',
      component: main,
      children: [
        {
          path: 'subview',
          name: 'subview',
          components: {
            chatlist: Chatlist,
            chatmessage: Chatmessage
          }
        }
      ]
    }
  ]
})
